﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "WeakPtr.h"
#include "OwnerPtr.h"
#include "ElementId.h"
#include "UniIdentity.h"

#include <set>
#include "QDialog"
#include <QTableWidget>
#include "ui_GraphicsStyleDlg.h"

/// 本文件是界面实现的辅助类，仅包含非常少的GDMP API的演示内容

namespace gcmp
{
    class IUiView;
    class IUiDocument;
    class IDocument;
    class IModelView;
    class IGraphicsStyleData;
    class IGraphicsStyleDataOverrideItems;
    class IGraphicsStyleDataValiditySettings;
}

namespace Sample
{
    struct GraphicsOverrideData;
    class GraphicsStyleTable;

    // 【显示样式探针】和【节点树样式探针】的对话框
    class GraphicsStyleDlg : public QDialog
    {
        Q_OBJECT
    public:
        GraphicsStyleDlg(gcmp::IUiDocument* pUIDoc, gcmp::IUiView* currentView, 
            std::wstring& title, std::vector<gcmp::OwnerPtr<Sample::GraphicsOverrideData>>& gOverrideDataList);
        ~GraphicsStyleDlg();

    private:
        void onMoveRequested(const QPoint& cursorPos, const QPoint& offset);

    protected:
        private slots:
        void OnApply();
    private:
        Ui::GraphicsStyleDialog m_ui;

        gcmp::WeakPtr<gcmp::IUiView> m_wpCurrentView;
        gcmp::WeakPtr<gcmp::IUiDocument> m_wpUIDoc;
        gcmp::OwnerPtr<QMouseEvent> m_opApplyBntMouseEvent;

        // 嵌套在Tab中的显示样式表格
        std::vector<gcmp::OwnerPtr<GraphicsStyleTable>> m_opTables;
        // 显示样式数据的包装类
        std::vector<gcmp::OwnerPtr<GraphicsOverrideData>>& m_gOverrideDataList;
    };
}

